/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.quickorm.core.impl;

import com.quickorm.core.PagedList;
import java.util.Collection;
import java.util.LinkedList;

/**
 *
 * @author aaa
 */
public class PagedListImpl<T> extends LinkedList<T> implements PagedList<T> {

    private int recordCount;
    private int pageIndex;
    private int pageSize;

    public PagedListImpl(Collection<T> list) {
        super(list);
    }

    /**
     * @return the recordCount
     */
    public int getRecordCount() {
        return recordCount;
    }

    /**
     * @param recordCount the recordCount to set
     */
    public void setRecordCount(int recordCount) {
        this.recordCount = recordCount;
    }

    /**
     * @return the pageIndex
     */
    public int getPageIndex() {
        return pageIndex;
    }

    /**
     * @param pageIndex the pageIndex to set
     */
    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    /**
     * @return the pageSize
     */
    public int getPageSize() {
        return pageSize;
    }

    /**
     * @param pageSize the pageSize to set
     */
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    /**
     * 根据总记录数、页大小计算得到页数
     *
     * @return
     */
    public int getPageCount() {
        if (pageSize == 0) {
            return 0;
        }
        int tmpPageCount = recordCount / pageSize;
        if (recordCount % pageSize != 0) {
            tmpPageCount = tmpPageCount + 1;
        }
        return tmpPageCount;
    }
}
